package com.ushine.web.log.controller;

import com.ushine.web.component.page.PageRequestQuery;
import com.ushine.web.component.page.ParamsQuery;
import com.ushine.web.component.page.QueryVO;
import com.ushine.web.log.annotation.SystemControllerLog;
import com.ushine.web.log.constant.LogConstant;
import com.ushine.web.log.model.Log;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: yangh
 * @Date: 2021/5/10 10:15
 * @Description: 日志测试Demo
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("log/test")
@Api(tags = "日志模块-日志参数解析")
public class LogTestController {

    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "单个参数")
    @PostMapping(value = "oneParam")
    public void oneParam(@RequestBody QueryVO<ParamsQuery> queryVO) {
        log.info("单个参数：" + queryVO);
    }

    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "多个参数")
    @PostMapping(value = "moreParams")
    public void moreParams(@RequestBody QueryVO<List<ParamsQuery>> queryVO) {
        log.info("多个参数：" + queryVO);
    }

    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "普通多个参数")
    @PostMapping(value = "moreStringParams")
    public void moreStringParams(@RequestBody QueryVO<List<String>> queryVO) {
        log.info("多个参数：" + queryVO);
    }

    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "分页参数")
    @PostMapping(value = "pageParams")
    public void pageParams(@RequestBody QueryVO<PageRequestQuery> queryVO) {
        log.info("分页参数：" + queryVO);
    }

    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "普通分页参数")
    @PostMapping(value = "pageRequsetParams")
    public void pageRequsetParams(@RequestBody PageRequestQuery pageRequestQuery) {
        log.info("普通分页参数：" + pageRequestQuery);
    }

    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "单个实体类")
    @PostMapping(value = "oneEntity")
    public void oneEntityParams(@RequestBody QueryVO<Log> queryVO) {
        log.info("分页参数：" + queryVO);
    }

    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "原生单个参数")
    @PostMapping(value = "oneRequestParam")
    public void oneRequestParam(@ApiParam(value = "原生第一个参数", required = true) @RequestParam("id") String id) {
        log.info("分页参数：" + id);
    }

    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "原生多个参数")
    @PostMapping(value = "moreRequestParam")
    public void moreRequestParam(@ApiParam(value = "原生第一个参数", required = true) @RequestParam("id") String id,
                                 @ApiParam(value = "原生第二个参数", required = true) @RequestParam("name") String name) {
        log.info("分页参数：" + id);
    }

    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "原生单个实体类")
    @PostMapping(value = "requestBody")
    public void requestBody(@RequestBody Log systemLog) {
        log.info("单个参数：" + systemLog);
    }

    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "原生requestListBody")
    @PostMapping(value = "requestListBody")
    public void requestListBody(@ApiParam(value = "list集合参数", required = true) @RequestBody List<String> list) {
        log.info("单个参数：" + list);
    }


    @SystemControllerLog(operation = LogConstant.READ)
    @ApiOperation(value = "原生实体类集合")
    @PostMapping(value = "requestEntityListBody")
    public void requestEntityListBody(@ApiParam(value = "list集合实体类参数", required = true) @RequestBody List<Log> mybatisDOList) {
        log.info("单个参数：" + mybatisDOList);
    }
}
